<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

	<head>

		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

        <!-- 移动端视口说明 -->
		<meta name="viewport" content="width=device-width,height=device-height,initial-scale=1.0,maximum-scale=1.0,user-scalable=no">

		<title><?php echo C('WEB_TITLE');?></title>

		<link rel="stylesheet" href="/Public/css/common.css"/>

		<link rel="stylesheet" href="/Public/js/layui/css/layui.css"/>

        <link rel="stylesheet prefetch" href="/Public/js/photoswipe/photoswipe.css">

        <link rel="stylesheet prefetch" href="/Public/js/photoswipe/default-skin/default-skin.css">

		<link rel="stylesheet" href="/Public/mobile/css/crm-mobile-terminal.css"/>
		<link rel="stylesheet" href="/Public/js/jeDate/skin/jedate.css">
		<link rel="stylesheet" href="/Public/js/mobile-date/mobile-date.css">
		<link rel="stylesheet" href="/Public/js/mobileSelect/mobileSelect.css">

        <link rel="stylesheet" href="<?php echo C('MOBILE_ICON_HTTP');?>"/>

		<script type="text/javascript" >

			const moduleName = "<?php echo (MODULE_NAME); ?>";

		</script>

		<script type="text/javascript" src="/Public/js/jquery-1.9.1.min.js"></script>

		<script type="text/javascript" src="/Public/js/cookie/jquery.cookie.js"></script>

		<script type="text/javascript" src="/Public/js/lang/<?php echo (getStrToLower(cookie('think_language'))); ?>.js"></script>

		<script type="text/javascript" src="/Public/js/layer/layer.js"></script>

		<script type="text/javascript" src="/Public/js/layui/layui.js"></script>

		<script type="text/javascript" src="/Public/js/WeChat/wechatglobal.js"></script>

		<script type="text/javascript" src="/Public/js/WeChat/wechatupload.js"></script>

		<script type="text/javascript" src="/Public/js/photoswipe/photoswipe.min.js"></script>

		<script type="text/javascript" src="/Public/js/photoswipe/photoswipe-ui-default.min.js"></script>

        <script type="text/javascript" src="/Public/js/WeChat/iscroll.js"></script>

		<script type="text/javascript" src="/Public/js/mobile-date/mobile-date.js"></script>
		
		<script type="text/javascript" src="/Public/js/jeDate/src/jedate.js"></script>
		
		<script type="text/javascript" src="/Public/mobile/js/crm-window.js"></script>
		
		<script type="text/javascript" src="/Public/js/feeldesk-slide.js"></script>

		<script type="text/javascript" src="/Public/js/photoswipe/photohtml.js"></script>

		<style type="text/css">

            body{background-color: #fafafa}

        </style>

		<script type="text/javascript" src="/Public/js/uni.webview.1.5.2.js"></script>

		<script type="text/javascript">

			//整合版：当前页为首页发送消息给整合系统并更改页面样式
			if(self!=top)
			{
				var isIframe=true;
			}

			var isFeelecApp = false;

			if(isIframe)
			{
				document.addEventListener("UniAppJSBridgeReady", function ()
				{
					uniPostHome();
				});
			}

			document.addEventListener('UniAppJSBridgeReady', function()
			{
				uni.getEnv(function(res)
				{
					if (res.plus)//res.h5
					{
						isFeelecApp = true;

						uniPostHome();
					}
				});
			});

			function uniPostHome()
			{
				var think_controller = "<?php echo (CONTROLLER_NAME); ?>";
				var think_action = "<?php echo (ACTION_NAME); ?>";

				if(think_controller+"/"+think_action == "Index/index")
				{
					uni.postMessage({
						data: {
							isHome: true
						}
					});
				}
				else
				{
					uni.postMessage({
						data: {
							isHome: false
						}
					});
				}
			}

		</script>

	</head>

    <body>



<div class="feeldesk" id="formWrapper">

    <header>

        <div class="menu-header">

            <a href="javascript:history.go(-1)" class="iconfont icon-back-left back"></a>

            <div class="header-title"><?php echo L('ADD_CUSTOMER');?></div>

            <a href="javascript:" class="header-right" id="submitForm"><?php echo L('COMPLETE');?></a>

        </div>

    </header>

    <div class="customer-label hidden">

        <div class="current" data-value="1"><?php echo L('BASIC_INFORMATION');?></div>

        <div data-value="2"><?php echo L('PRIMARY_CONTACT');?></div>

    </div>

    <div class="feeldesk-main no-footer-main pd0" style="height: calc(100% -  16vw)" >

        <form action="" id="feeldeskForm" method="post" class="layui-form">

			<?php $ft = 0; $reg = 0; ?>

            <div class="feeldesk-form pd5" id="customer-label1">

                <div class="feeldesk-form-item">

                    <div class="feeldesk-form-block">

                        <select name="customer[member_id]" lay-filter="">

                            <option value="0"><?php echo L('SELECT_CUSTOMER_RESPONSIBLE');?></option>

                            <?php if(is_array($members)): $i = 0; $__LIST__ = $members;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$v): $mod = ($i % 2 );++$i;?><option value="<?php echo ($v["member_id"]); ?>" <?php if(empty($type)): if(($thisMember["member_id"]) == $v["member_id"]): ?>selected<?php endif; endif; ?>><?php echo ($v["name"]); ?></option><?php endforeach; endif; else: echo "" ;endif; ?>

                        </select>

                    </div>

                </div>

				<input type="hidden" name="customer[from_type]" value="<?php echo ($fromType); ?>"/>

				<input type="hidden" name="customer[originalId]" value="<?php echo ($apiData["originalId"]); ?>"/>

				<?php if($crmsite['customerReseller'] == 1): ?><div class="feeldesk-form-item relative">

					<div class="feeldesk-form-block">

						<span class="red required-icon">*</span>

						<div class="feeldesk-input feeldesk-form-check radio name-radio"><span><?php echo L('CUSTOMER_TYPE');?></span><i class="feeldesk-edge"></i></div>

						<ul class="feeldesk-option-panel radioPanel hidden">

							<input type="hidden" name="customer[customer_type]" value="customer"/>

							<li data-name="<?php echo L('ORDINARY_CUSTOMER');?>" data-value="customer">

								<div class="feeldesk-option">

									<span class="feeldesk-option-title"><?php echo L('ORDINARY_CUSTOMER');?></span>

									<span class="iconfont icon-check icon-radio-checked"></span>

								</div>

							</li>

							<li data-name="<?php echo L('DEALER');?>" data-value="agent">

								<div class="feeldesk-option">

									<span class="feeldesk-option-title"><?php echo L('DEALER');?></span>

									<span class="iconfont icon-check"></span>

								</div>

							</li>

						</ul>

					</div>

                </div><?php endif; ?>

				<?php if(is_array($customerform)): $i = 0; $__LIST__ = $customerform;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?><!-- 字段未设置查看范围或当前用户角色在查看范围内 -->
				<?php if(!$vo['role_id'] || in_array($mobile['role_id'],explode(',',$vo['role_id']))): if(($vo["form_type"]) == "region"): $reg++; ?>

						<?php echo W('Region/getRegion',['customer_form',$vo,$reg]);?>

					<?php else: ?>

					 <div class="feeldesk-form-item relative">

						<div class="feeldesk-form-block">

							<?php if(($vo["is_required"]) == "0"): ?><span class="red required-icon">*</span><?php endif; ?>

							<?php if(($vo["form_type"]) == "text"): ?><!-- 单行文本框 -->
								<input type="text" name="customer_form[<?php echo ($vo["form_name"]); ?>]" value="<?php echo ($customerData[$vo['form_name']]); ?>" placeholder="<?php echo ($vo["form_description"]); ?>" class="feeldesk-input"/><?php endif; ?>

							<?php if(($vo["form_type"]) == "phone"): ?><!-- 手机 -->
								<input type="text" onKeyPress="if (event.keyCode!=46 && event.keyCode!=45 && event.keyCode<48 || event.keyCode>57) event.returnValue=false" name="customer_form[<?php echo ($vo["form_name"]); ?>]" value="<?php echo ($customerData[$vo['form_name']]); ?>" placeholder="<?php echo ($vo["form_description"]); ?>" class="feeldesk-input"/><?php endif; ?>

							<?php if(($vo["form_type"]) == "email"): ?><!-- 邮箱 -->
								<input type="text" name="customer_form[<?php echo ($vo["form_name"]); ?>]" value="<?php echo ($customerData[$vo['form_name']]); ?>" placeholder="<?php echo ($vo["form_description"]); ?>" class="feeldesk-input"/><?php endif; ?>

							<?php if(($vo["form_type"]) == "number"): ?><!-- 数字 -->
								<input type="number" onKeyPress="if (event.keyCode!=46 && event.keyCode!=45 && event.keyCode<48 || event.keyCode>57) event.returnValue=false" name="customer_form[<?php echo ($vo["form_name"]); ?>]" value="" placeholder="<?php echo ($vo["form_description"]); ?>" class="feeldesk-input"/><?php endif; ?>

							<?php if(($vo["form_type"]) == "decimal"): ?><!-- 小数 -->
								<input type="text" name="customer_form[<?php echo ($vo["form_name"]); ?>]" value="" placeholder="<?php echo ($vo["form_description"]); ?>" class="feeldesk-input"/><?php endif; ?>

							<?php if(($vo["form_type"]) == "select"): ?><!-- 下拉菜单 -->
								<select name="customer_form[<?php echo ($vo["form_name"]); ?>]" lay-filter="">

									<option value=""><?php echo ($vo["form_description"]); ?></option>

									<?php if(is_array($vo["option"])): foreach($vo["option"] as $key=>$op): ?><option value="<?php echo ($op); ?>"><?php echo ($op); ?></option><?php endforeach; endif; ?>

								</select><?php endif; ?>

							<?php if(($vo["form_type"]) == "select_text"): $st++; ?>
								<!-- 下拉填写 -->
								<?php echo W('Update/selectTextForm',['customer',$vo,$st]); endif; ?>

							<?php if(($vo["form_type"]) == "checkbox"): ?><!-- 多选 -->
                                <div class="feeldesk-input feeldesk-form-check checkbox">

                                    <span class='gray9'><?php echo ($vo["form_description"]); ?></span>

                                    <i class="feeldesk-edge"></i>

                                </div>

                                <ul class="feeldesk-option-panel hidden checkboxPanel">

                                    <?php if(is_array($vo["option"])): $i = 0; $__LIST__ = $vo["option"];if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$op): $mod = ($i % 2 );++$i;?><li data-value="<?php echo ($op); ?>">

                                            <input type="checkbox" name="customer_form[<?php echo ($vo["form_name"]); ?>][]" value="<?php echo ($op); ?>"/>

                                            <div class="feeldesk-option">

                                                <span class="feeldesk-option-title"><?php echo ($op); ?></span>

                                                <span class="iconfont icon-check"></span>

                                            </div>

                                        </li><?php endforeach; endif; else: echo "" ;endif; ?>

                                </ul><?php endif; ?>

							<?php if(($vo["form_type"]) == "radio"): ?><!-- 单选 -->
								<div class="feeldesk-input feeldesk-form-check radio name-radio"><span><?php echo ($vo["form_description"]); ?></span><i class="feeldesk-edge"></i></div>

								<ul class="feeldesk-option-panel radioPanel hidden">

									<input type="hidden" name="customer_form[<?php echo ($vo["form_name"]); ?>]" value=""/>

									<?php if(is_array($vo["option"])): $i = 0; $__LIST__ = $vo["option"];if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$op): $mod = ($i % 2 );++$i;?><li data-name="<?php echo ($op); ?>" data-value="<?php echo ($op); ?>">

										<div class="feeldesk-option">

											<span class="feeldesk-option-title"><?php echo ($op); ?></span>

											<span class="iconfont icon-check"></span>

										</div>

									</li><?php endforeach; endif; else: echo "" ;endif; ?>

								</ul><?php endif; ?>

							<!-- 文本域 -->
							<?php if(($vo["form_type"]) == "textarea"): ?><textarea name="customer_form[<?php echo ($vo["form_name"]); ?>]" class="feeldesk-input feeldesk-textarea" placeholder="<?php echo ($vo["form_description"]); ?>"></textarea><?php endif; ?>

							<!-- 时间控件 -->
							<?php if(($vo["form_type"]) == "date"): $ft++; ?>

								<input type="text" name="customer_form[<?php echo ($vo["form_name"]); ?>]" value="" placeholder="<?php echo ($vo["form_description"]); ?>" id="datetime<?php echo $ft; ?>" class="feeldesk-input" readonly />

                                <script type="text/javascript">

                                    $(function()
                                    {
                                        jeDate("#datetime<?php echo $ft; ?>",{
											minDate:"1900-01-01",              //最小日期
											maxDate:"2099-12-31",              //最大日期
											method:{
												choose:function (params) {

												}
											},
											format: "YYYY-MM-DD hh:mm:ss"
										});
                                    })

                                </script><?php endif; ?>

						</div>

					</div><?php endif; endif; endforeach; endif; else: echo "" ;endif; ?>

            </div>

            <!-- <?php echo L('PRIMARY_CONTACT');?> -->
            <div class="feeldesk-form pd5 hidden" id="customer-label2">

                <?php if(is_array($contacterform)): $i = 0; $__LIST__ = $contacterform;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?><!-- 字段未设置查看范围或当前用户角色在查看范围内 -->
				<?php if(!$vo['role_id'] || in_array($mobile['role_id'],explode(',',$vo['role_id']))): if(($vo["form_type"]) == "region"): $reg++; ?>

						<?php echo W('Region/getRegion',['contacter_form',$vo,$reg]);?>

					<?php else: ?>

					 <div class="feeldesk-form-item relative">

						<div class="feeldesk-form-block">

							<?php if(($vo["is_required"]) == "0"): ?><span class="red required-icon">*</span><?php endif; ?>

							<?php if(($vo["form_type"]) == "text"): ?><!-- 单行文本框 -->
								<input type="text" name="contacter_form[<?php echo ($vo["form_name"]); ?>]" value="<?php echo ($contacterData[$vo['form_name']]); ?>" placeholder="<?php echo ($vo["form_description"]); ?>" class="feeldesk-input"/><?php endif; ?>

							<?php if(($vo["form_type"]) == "phone"): ?><!-- 手机 -->
								<input type="text" onKeyPress="if (event.keyCode!=46 && event.keyCode!=45 && event.keyCode<48 || event.keyCode>57) event.returnValue=false" name="contacter_form[<?php echo ($vo["form_name"]); ?>]" value="<?php echo ($contacterData[$vo['form_name']]); ?>" placeholder="<?php echo ($vo["form_description"]); ?>" class="feeldesk-input"/><?php endif; ?>

							<?php if(($vo["form_type"]) == "email"): ?><!-- 邮箱 -->
								<input type="text" name="contacter_form[<?php echo ($vo["form_name"]); ?>]" value="<?php echo ($contacterData[$vo['form_name']]); ?>" placeholder="<?php echo ($vo["form_description"]); ?>" class="feeldesk-input"/><?php endif; ?>

							<?php if(($vo["form_type"]) == "number"): ?><!-- 数字 -->
								<input type="number" onKeyPress="if (event.keyCode!=46 && event.keyCode!=45 && event.keyCode<48 || event.keyCode>57) event.returnValue=false" name="contacter_form[<?php echo ($vo["form_name"]); ?>]" value="" placeholder="<?php echo ($vo["form_description"]); ?>" class="feeldesk-input"/><?php endif; ?>

							<?php if(($vo["form_type"]) == "decimal"): ?><!-- 小数 -->
								<input type="text" name="contacter_form[<?php echo ($vo["form_name"]); ?>]" value="" placeholder="<?php echo ($vo["form_description"]); ?>" class="feeldesk-input"/><?php endif; ?>

							<?php if(($vo["form_type"]) == "select"): ?><!-- 下拉菜单 -->
								<select name="contacter_form[<?php echo ($vo["form_name"]); ?>]" lay-filter="">

									<option value=""><?php echo ($vo["form_description"]); ?></option>

									<?php if(is_array($vo["option"])): foreach($vo["option"] as $key=>$op): ?><option value="<?php echo ($op); ?>"><?php echo ($op); ?></option><?php endforeach; endif; ?>

								</select><?php endif; ?>
							
							<?php if(($vo["form_type"]) == "select_text"): $st++; ?>
								<!-- 下拉填写 -->
								<?php echo W('Update/selectTextForm',['contacter',$vo,$st]); endif; ?>

							<?php if(($vo["form_type"]) == "checkbox"): ?><!-- 多选 -->
                                <div class="feeldesk-input feeldesk-form-check checkbox">

                                    <span class='gray9'><?php echo ($vo["form_description"]); ?></span>

                                    <i class="feeldesk-edge"></i>

                                </div>

                                <ul class="feeldesk-option-panel hidden checkboxPanel">

                                    <?php if(is_array($vo["option"])): $i = 0; $__LIST__ = $vo["option"];if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$op): $mod = ($i % 2 );++$i;?><li data-value="<?php echo ($op); ?>">

                                            <input type="checkbox" name="contacter_form[<?php echo ($vo["form_name"]); ?>][]" value="<?php echo ($op); ?>"/>

                                            <div class="feeldesk-option">

                                                <span class="feeldesk-option-title"><?php echo ($op); ?></span>

                                                <span class="iconfont icon-check"></span>

                                            </div>

                                        </li><?php endforeach; endif; else: echo "" ;endif; ?>

                                </ul><?php endif; ?>

							<?php if(($vo["form_type"]) == "radio"): ?><!-- 单选 -->
								<div class="feeldesk-input feeldesk-form-check radio name-radio"><span><?php echo ($vo["form_description"]); ?></span><i class="feeldesk-edge"></i></div>

								<ul class="feeldesk-option-panel radioPanel hidden">

									<input type="hidden" name="contacter_form[<?php echo ($vo["form_name"]); ?>]" value=""/>

									<?php if(is_array($vo["option"])): $i = 0; $__LIST__ = $vo["option"];if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$op): $mod = ($i % 2 );++$i;?><li data-name="<?php echo ($op); ?>" data-value="<?php echo ($op); ?>">

										<div class="feeldesk-option">

											<span class="feeldesk-option-title"><?php echo ($op); ?></span>

											<span class="iconfont icon-check"></span>

										</div>

									</li><?php endforeach; endif; else: echo "" ;endif; ?>

								</ul><?php endif; ?>

							<!-- 文本域 -->
							<?php if(($vo["form_type"]) == "textarea"): ?><textarea name="contacter_form[<?php echo ($vo["form_name"]); ?>]" class="feeldesk-input feeldesk-textarea" placeholder="<?php echo ($vo["form_description"]); ?>"></textarea><?php endif; ?>

							<!-- 时间控件 -->
							<?php if(($vo["form_type"]) == "date"): $ft++; ?>

								<input type="text" name="contacter_form[<?php echo ($vo["form_name"]); ?>]" value="" placeholder="<?php echo ($vo["form_description"]); ?>" id="datetime<?php echo $ft; ?>" class="feeldesk-input" readonly />

                                <script type="text/javascript">

                                    $(function()
                                    {
                                        jeDate("#datetime<?php echo $ft; ?>",{
											minDate:"1900-01-01",              //最小日期
											maxDate:"2099-12-31",              //最大日期
											method:{
												choose:function (params) {

												}
											},
											format: "YYYY-MM-DD hh:mm:ss"
										});
                                    })

                                </script><?php endif; ?>

						</div>

					</div><?php endif; endif; endforeach; endif; else: echo "" ;endif; ?>

            </div>

        </form>

    </div>

    <script type="text/javascript">

        $(function()
        {
           $('.customer-label').find('div').on('click',function()
           {
               var value= $(this).data('value');

               $(this).addClass('current').siblings().removeClass('current');

                $('#customer-label'+value).show().siblings('.feeldesk-form').hide();
           })
        })

    </script>

</div>